implicit differentiation and chain rule